﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

//数组中只出现一次的数（其它数出现k次）
//https://www.nowcoder.com/practice/5d3d74c3bf7f4e368e03096bb8857871?tpId=188&&tqId=38592&rp=1&ru=/activity/oj&qru=/ta/job-code-high-week/question-ranking
class Solution {
public:
    int foundOnceNumber(vector<int>& arr, int k) {
        unordered_map<int,int> m;
        for(const auto& n:arr) ++m[n];

        for(const auto& kv:m)
            if(kv.second == 1) return kv.first;
        
        return -1;
    }
};

//颠倒二进制位
//https://leetcode.cn/problems/reverse-bits/description/
class Solution {
public:
    uint32_t reverseBits(uint32_t n) {
        uint32_t ret = 0;
        int bit = 31;
        while(n)
        {
            ret += pow(2*(n & 1),bit--);
            n >>= 1;
        }
        return ret;
    }
};

